package com.woniuxy.commons.service.factory;

import com.woniuxy.commons.entity.DisabledAddress;
import com.woniuxy.commons.service.FeignAddressService;
import com.woniuxy.commons.util.ResponseResult;
import com.woniuxy.commons.util.ResultStatus;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class FeignAddressServiceFactory implements FallbackFactory<FeignAddressService> {
    @Override
    public FeignAddressService create(Throwable cause) {
        return new FeignAddressService() {
            @Override
            public ResponseResult findAddressByDisabledId(int did) {
                ResponseResult responseResult = new ResponseResult();
                responseResult.setCode(500);
                responseResult.setStatus(ResultStatus.FAIL);
                responseResult.setMsg("服务已降级");
                return responseResult;
            }

            @Override
            public ResponseResult addAddress(DisabledAddress address) {
                ResponseResult responseResult = new ResponseResult();
                responseResult.setCode(500);
                responseResult.setStatus(ResultStatus.FAIL);
                responseResult.setMsg("服务已降级");
                return responseResult;
            }

            @Override
            public ResponseResult delAddress(int id) {
                ResponseResult responseResult = new ResponseResult();
                responseResult.setCode(500);
                responseResult.setStatus(ResultStatus.FAIL);
                responseResult.setMsg("服务已降级");
                return responseResult;
            }

            @Override
            public ResponseResult delAddress(DisabledAddress address) {
                ResponseResult responseResult = new ResponseResult();
                responseResult.setCode(500);
                responseResult.setStatus(ResultStatus.FAIL);
                responseResult.setMsg("服务已降级");
                return responseResult;
            }
        };
    }
}
